package com.example.demo.controller;

import com.example.demo.entity.Examine;
import com.example.demo.param.ExamineParam;
import com.example.demo.service.ExamineService;
import com.example.demo.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/examine")
public class ExamineController {

    @Resource
    private ExamineService examineService;

    /*
     * type = 0 为动态本身
     * type = 1 为古诗评论,type = 2为动态评论
     * */
    @GetMapping("/add")
    public Result addObject(Long id,Integer type){
        return examineService.addObject(id,type);
    }

    @GetMapping("/select")
    public Result selectObject(Integer pageNo){
        List<Examine> examines = examineService.selectObject(pageNo);
        return Result.ok().data("data",examines);
    }

    @PostMapping("/check")
    public Result examine(@RequestBody ExamineParam examineParam){
        return examineService.examine(examineParam);
    }

}
